#include "led.h"



/*!
    \brief      LED parameter initialization
    \param[in]  none 
    \param[out] none
    \retval     none
*/
void led_init(void)
{
	GPIO_InitTypeDef led_structure;
	
	RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOF,ENABLE);
	
	led_structure.GPIO_Mode=GPIO_Mode_OUT;
	led_structure.GPIO_OType=GPIO_OType_PP;
	led_structure.GPIO_Pin=GPIO_Pin_11|GPIO_Pin_12;
	led_structure.GPIO_PuPd=GPIO_PuPd_NOPULL;
	led_structure.GPIO_Speed=GPIO_Low_Speed;
	
	GPIO_Init(GPIOF,&led_structure);
}


/*!
    \brief      Turn on LEDS
    \param[in]  led_type: led_x(x = 1,2,all) 
                only one parameter can be selected which is shown as below:
      \arg        led_1: Turn on led1
      \arg        led_2: Turn on led2
      \arg        led_all: Turn on led1 and led2
    \param[out] none
    \retval     none
*/
void led_on(led_type led)
{
	switch(led)
	{
		case led_1:GPIO_ResetBits(GPIOF,GPIO_Pin_11);break;
		case led_2:GPIO_ResetBits(GPIOF,GPIO_Pin_12);break;
		case led_all:
					GPIO_ResetBits(GPIOF,GPIO_Pin_11);
					GPIO_ResetBits(GPIOF,GPIO_Pin_12);break;
	}
}


/*!
    \brief      Turn off LEDS
    \param[in]  led_type: led_x(x = 1,2,all) 
                only one parameter can be selected which is shown as below:
      \arg        led_1: Turn off led1
      \arg        led_2: Turn off led2
      \arg        led_all: Turn off led1 and led2
    \param[out] none
    \retval     none
*/
void led_off(led_type led)
{
	switch(led)
	{
		case led_1:GPIO_SetBits(GPIOF,GPIO_Pin_11);break;
		case led_2:GPIO_SetBits(GPIOF,GPIO_Pin_12);break;
		case led_all:
					GPIO_SetBits(GPIOF,GPIO_Pin_11);
					GPIO_SetBits(GPIOF,GPIO_Pin_12);break;
	}
}

/*!
    \brief      Toggle LEDS statues
    \param[in]  led_type: led_x(x = 1,2,all) 
                only one parameter can be selected which is shown as below:
      \arg        led_1: Toggle led1
      \arg        led_2: Toggle led2
      \arg        led_all: Toggle led1 and led2
    \param[out] none
    \retval     none
*/
void led_toggle(led_type led)
{
	switch(led)
	{
		case led_1:GPIO_ToggleBits(GPIOF,GPIO_Pin_11);break;
		case led_2:GPIO_ToggleBits(GPIOF,GPIO_Pin_12);break;
		case led_all:
					GPIO_ToggleBits(GPIOF,GPIO_Pin_11);
					GPIO_ToggleBits(GPIOF,GPIO_Pin_12);break;
	}
}

